﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using autobackup.util;

namespace autobackup.job
{
    class BackUpJob : IJob
    {
        public void Execute(IJobExecutionContext context)
        {

            Form1.instance.logMain("正在执行任务");


            JobDataMap dataMap = context.JobDetail.JobDataMap;
            string pathFormStr = dataMap.GetString("pathFroms");
            string[] pathForms = pathFormStr.Split(new string[] { Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
            
            string pathTo = dataMap.GetString("pathTo");
            

            //复制文件
            FileUtil.startMutilCopy(pathForms, pathTo);


            //更新form上面的显示信息
            Form1.instance.showJob();
            Form1.instance.logMain("本次任务共处理文件 " + FileUtil.total + " 个, 不需要复制的文件 " + FileUtil.noCopy + " 个");

            Console.WriteLine("Hello " + DateTime.Now.ToString());
        }
    }
}
